import shutil
import os
import xml.etree.ElementTree as ET

src = './101_已标注/'
tar = './101已标注_filt/'

if not os.path.exists(tar):
	os.mkdir(tar)
else:
	shutil.rmtree(tar)
	os.mkdir(tar)

lst = os.listdir(src)
	
for name in lst:
	if name.endswith('xml'):
		continue
	name = name.strip()
	xml = name[:-3] + "xml"
	copyflag = False
	if os.path.exists(src +xml):
		with open(src+xml,'r',encoding='utf-8') as f:
			for line in f:
				if 'bndbox' in line:
					copyflag = True
					break
	if copyflag:
		print("copy "+name)
		shutil.copy(src +name,tar)
		shutil.copy(src +xml,tar)